package company.wangyi_F;

import java.util.*;

public class Wang1 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        int max = 0;
        Set<Integer> set = new TreeSet<>();
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
            max = Math.max(array[i], max);
        }
        for (int i = 2; i <= max; i++) {
            if (judgePrime(i))
                set.add(i);
        }
        System.out.println(set);
        int[] dp = new int[max + 1];
        dp[0] = 0;
        dp[1] = 0;
        for (int i = 2; i <= max; i++) {
            int tmpMax = 0;
            for (Integer num : set) {
                if (num > i)
                    break;
                tmpMax = Math.max(tmpMax, dp[i - num]);
            }
            dp[i] = tmpMax + 1;
        }
        int result = 0;
        for (int num : array) {
            result += dp[num];
        }
        System.out.println(result);
    }

    public static boolean judgePrime(int num) {
        boolean flag = true;
        if (num == 1 || (num % 2 == 0 && num != 2)) flag = false;
        else for (int j = 3; j <= Math.sqrt(num); j += 2) {
            if (num % j == 0) flag = false;
        }
        return flag;
    }
}
